import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
import axios from "axios";

export const fetchBannerAction = createAsyncThunk('banner/fetchBanner', 
  async (extraInfo,{dispatch,getState}) => { 
  const res = await axios.get('http://123.207.32.32:8000/home/multidata')
  console.log(res.data.data.banner.list)
  dispatch(setBanner(res.data.data.banner.list))
  return res.data.data.banner.list
})

const bannerSlice = createSlice({
  name: 'banner',
  initialState: {
    banner: []
  },
  reducers: {
    setBanner(state, action) {
      state.banner = action.payload
    }
  }
})

export const { setBanner } = bannerSlice.actions
export default bannerSlice.reducer